﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kaskelot.Services.Model;

namespace Stockholm.SOA.Kaskelot.WCF.ServiceImplementation.Mapping
{
	public static class MaterielTypMaterielTypExtensions
	{
		public static DataContracts.MaterielTypMaterielTyp ToContract(this MaterielTypMaterielTyp entity)
		{
			DataContracts.MaterielTypMaterielTyp b = new DataContracts.MaterielTypMaterielTyp();

			CopyFromEntity(entity, b, false);

			return b;
		}

		public static DataContracts.MaterielTypMaterielTyp ToMinimalContract(this MaterielTypMaterielTyp entity)
		{
			DataContracts.MaterielTypMaterielTyp b = new DataContracts.MaterielTypMaterielTyp();

			CopyFromEntity(entity, b, true);

			return b;
		}

		public static MaterielTypMaterielTyp ToEntity(this DataContracts.MaterielTypMaterielTyp b)
		{
			MaterielTypMaterielTyp entity = new MaterielTypMaterielTyp();

			CopyToEntity(b, entity);

			return entity;
		}

		public static void UpdateEntity(this MaterielTypMaterielTyp entity, DataContracts.MaterielTypMaterielTyp mtmt)
		{
			CopyToEntity(mtmt, entity);
		}

		private static void CopyFromEntity(MaterielTypMaterielTyp from, DataContracts.MaterielTypMaterielTyp to, bool minimal)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;
			to.ChildId = from.ChildId;
			to.ParentId = from.ParentId;
			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;
		}

		private static void CopyToEntity(DataContracts.MaterielTypMaterielTyp from, MaterielTypMaterielTyp to)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;
			to.ChildId = from.ChildId;
			to.ParentId = from.ParentId;
			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;
		}
	}
}
